package top.xia17.plugins.fast.common.database.mybatis.extension;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Collection;

/**
 * mybatis-plus 的基础Service的实现
 * create update delete 添加事务
 * @author xia17
 * @since 2021/12/1 15:16
 */
public class IbatisTxServiceImpl<T extends IbatisEntity<ID>, ID extends Serializable, M extends BaseMapper<T>>  extends IbatisServiceImpl<T,ID,M> {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public T create(T resource) {
        return super.create(resource);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public T update(T resource) {
        return super.update(resource);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteById(ID id) {
        super.deleteById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteById(Collection<ID> ids) {
        super.deleteById(ids);
    }
}
